<div class="box">
    <div class="box-header">
        <h3 class="box-title">VIP订单统计</h3>
        <div class="box-tools pull-right">
            <ob_link><a class="btn btn-primary" href="{:url('orderlist')}"><i class="fa fa-list"></i> 订单列表</a></ob_link>
        </div>
    </div>
    
    <div class="box-body">
        <!-- 统计卡片 -->
        <div class="row">
            <div class="col-md-3 col-sm-6 col-xs-12">
                <div class="info-box">
                    <span class="info-box-icon bg-aqua"><i class="fa fa-shopping-cart"></i></span>
                    <div class="info-box-content">
                        <span class="info-box-text">总订单数</span>
                        <span class="info-box-number">{$stats.total_orders|default=0}</span>
                    </div>
                </div>
            </div>
            
            <div class="col-md-3 col-sm-6 col-xs-12">
                <div class="info-box">
                    <span class="info-box-icon bg-green"><i class="fa fa-money"></i></span>
                    <div class="info-box-content">
                        <span class="info-box-text">总收入</span>
                        <span class="info-box-number">¥{$stats.total_income|default=0}</span>
                    </div>
                </div>
            </div>
            
            <div class="col-md-3 col-sm-6 col-xs-12">
                <div class="info-box">
                    <span class="info-box-icon bg-yellow"><i class="fa fa-clock-o"></i></span>
                    <div class="info-box-content">
                        <span class="info-box-text">待支付订单</span>
                        <span class="info-box-number">{$stats.pending_orders|default=0}</span>
                    </div>
                </div>
            </div>
            
            <div class="col-md-3 col-sm-6 col-xs-12">
                <div class="info-box">
                    <span class="info-box-icon bg-red"><i class="fa fa-check-circle"></i></span>
                    <div class="info-box-content">
                        <span class="info-box-text">已支付订单</span>
                        <span class="info-box-number">{$stats.paid_orders|default=0}</span>
                    </div>
                </div>
            </div>
        </div>
        
        <!-- 今日统计 -->
        <div class="row">
            <div class="col-md-6 col-sm-6 col-xs-12">
                <div class="info-box">
                    <span class="info-box-icon bg-purple"><i class="fa fa-calendar"></i></span>
                    <div class="info-box-content">
                        <span class="info-box-text">今日订单数</span>
                        <span class="info-box-number">{$stats.today_orders|default=0}</span>
                    </div>
                </div>
            </div>
            
            <div class="col-md-6 col-sm-6 col-xs-12">
                <div class="info-box">
                    <span class="info-box-icon bg-orange"><i class="fa fa-rmb"></i></span>
                    <div class="info-box-content">
                        <span class="info-box-text">今日收入</span>
                        <span class="info-box-number">¥{$stats.today_income|default=0}</span>
                    </div>
                </div>
            </div>
        </div>
        
        <!-- 转化率统计 -->
        <div class="row">
            <div class="col-md-12">
                <div class="box">
                    <div class="box-header">
                        <h3 class="box-title">订单转化率分析</h3>
                    </div>
                    <div class="box-body">
                        <div class="row">
                            <div class="col-md-4">
                                <div class="description-block border-right">
                                    <span class="description-percentage text-green">
                                        <i class="fa fa-caret-up"></i> 
                                        {php}
                                        $conversion_rate = 0;
                                        if ($stats['total_orders'] > 0) {
                                            $conversion_rate = round(($stats['paid_orders'] / $stats['total_orders']) * 100, 2);
                                        }
                                        echo $conversion_rate;
                                        {/php}%
                                    </span>
                                    <h5 class="description-header">{$stats.paid_orders|default=0}</h5>
                                    <span class="description-text">支付转化率</span>
                                </div>
                            </div>
                            
                            <div class="col-md-4">
                                <div class="description-block border-right">
                                    <span class="description-percentage text-yellow">
                                        <i class="fa fa-caret-left"></i> 
                                        {php}
                                        $pending_rate = 0;
                                        if ($stats['total_orders'] > 0) {
                                            $pending_rate = round(($stats['pending_orders'] / $stats['total_orders']) * 100, 2);
                                        }
                                        echo $pending_rate;
                                        {/php}%
                                    </span>
                                    <h5 class="description-header">{$stats.pending_orders|default=0}</h5>
                                    <span class="description-text">待支付率</span>
                                </div>
                            </div>
                            
                            <div class="col-md-4">
                                <div class="description-block">
                                    <span class="description-percentage text-blue">
                                        <i class="fa fa-caret-up"></i> 
                                        {php}
                                        $avg_amount = 0;
                                        if ($stats['paid_orders'] > 0) {
                                            $avg_amount = round($stats['total_income'] / $stats['paid_orders'], 2);
                                        }
                                        echo $avg_amount;
                                        {/php}
                                    </span>
                                    <h5 class="description-header">¥{$stats.total_income|default=0}</h5>
                                    <span class="description-text">平均订单金额</span>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        
        <!-- 操作按钮 -->
        <div class="row">
            <div class="col-md-12">
                <div class="box">
                    <div class="box-header">
                        <h3 class="box-title">快捷操作</h3>
                    </div>
                    <div class="box-body">
                        <ob_link><a class="btn btn-primary" href="{:url('orderlist')}"><i class="fa fa-list"></i> 查看订单列表</a></ob_link>
                        &nbsp;
                        <ob_link><a class="btn btn-success" href="{:url('orderlist', ['status' => 1])}"><i class="fa fa-check"></i> 查看已支付订单</a></ob_link>
                        &nbsp;
                        <ob_link><a class="btn btn-warning" href="{:url('orderlist', ['status' => 0])}"><i class="fa fa-clock-o"></i> 查看待支付订单</a></ob_link>
                        <!-- &nbsp;
                        <ob_link><a class="btn btn-info" href="{:url('vip_order/export')}"><i class="fa fa-download"></i> 导出订单数据</a></ob_link> -->
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>